package com.jd.controller;

import com.common.model.Result;
import com.jd.model.ProductApplyCondition;
import com.jd.model.ProductApplyVO;
import com.jd.model.VCProductInfoCondition;
import com.jd.model.VCProductInfoVO;
import com.jd.service.JDProductApplyService;
import com.jd.service.JDProductInfoService;
import com.mrobuy.jdvc.entity.VCProductApply;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 *  JD商品申请管理
 */
@RestController
public class JDProductApplyController {

	private static Logger LOG = LoggerFactory.getLogger(JDProductApplyController.class);

	@Autowired
	private JdbcTemplate jdbcTemplate;

	@Autowired
	private JDProductApplyService jdProductApplyService;

	@RequestMapping("/common/applies")
	public Result<ProductApplyVO> applies(@ModelAttribute ProductApplyCondition condition) {
		return jdProductApplyService.loadProductApplies(condition);
	}

	@RequestMapping("/common/apply/reset")
	public Result<String> reset(@RequestParam("applyId") String applyId) {

		Result<String> result = new Result<>();

		 try {
			 jdProductApplyService.reset(applyId);
		 } catch (Exception e) {
			 LOG.error(e.getMessage(), e.getCause());
			 result.setCode(-1);
			 result.setMsg(e.getMessage());
		 }

		 return result;
	}


}
